<template>
  <div>
    <h1>增删改查</h1>
  </div>
  <div v-for="(item, index) in list" :key="item.id" v-stripe="index">
    {{ item.goods_name }}---{{ item.price }}---<button @click="del(item.id)">
      删除
    </button>
  </div>
</template>

<script lang="ts" setup>
import { reactive } from "vue";
// let autoID = 4;
let list = reactive([]);

import { getlist, dellist } from "@/utils/https";
//获取列表
getlist()
  .then((res) => {
    res.data.forEach((item) => {
      list.push(item);
    });
    console.log(res.data);
  })
  .catch((err) => {
    console.log(err);
  });

//删除
function del(id) {
	console.log(id);
	
  dellist({ id: id })
    .then((res) => {
      console.log(res);
    })
    .catch((err) => {
      console.log(err);
    });
}
</script>
<style lang='less' scoped>
</style>